package genericity_try;

public class GenericMethod {
    public static <E> void printAll(E[] arr){
        for(E o:arr){
            System.out.print(o+" ");
        }
        System.out.println();
    }

    public static <T extends Comparable<T>> T max(T x,T y,T z){
        T max = x;
        if(y.compareTo(max) > 0){
            max = y;
        }
        if(z.compareTo(max) > 0){
            max = z;
        }
        return max;
    }

    public static void main(String[] args) {
        Integer[] a={1,2,3,4,5,6,7};
        Number[] b={11,12,13,14,15,16,17};
        Character[] c={'a','b','c','d','e'};

        printAll(a);
        printAll(b);
        printAll(c);

        System.out.println("1.2  1.5  1.11中最大的是："+max(1.2 ,1.5 ,1.11));
        System.out.println("2  5  1中最大的是："+max(2 ,5 ,1));
        System.out.println("apple  banana  orange中最大的是："+max("apple" ,"banana" ,"orange"));
    }
}
